<?php

class tbdata_mdl_product extends dbeav_model{

	    public function getList($cols = '*', $filter = array(), $offset = 0, $limit = -1, $orderType = null){
			$rows = parent::getList($cols,$filter,$offset,$limit,$orderType);
			foreach($rows as $row){
				$ids[] = $row['id'];
			}
			$image_attach_model = app::get('image')->model('image_attach');
			$images = $image_attach_model->getList('image_id,target_id',array('target_id'=>$ids,'target_type'=>'product'),0,-1);
			foreach((array)$images as $image){
				$tmp_image[$image['target_id']][] = $image['image_id'];
			}
			foreach($rows as &$row){
				$row['images'] = $tmp_image[$row['id']];
			}
			return $rows;
		}

		public function dump($filter,$field = '*',$subSdf = null){
			$data = parent::dump($filter,$field,$subSdf);

			$image_attach_model = app::get('image')->model('image_attach');

			$images = $image_attach_model->getList('image_id,target_id',array('target_id'=>$data['id'],'target_type'=>'product'),0,-1);

			foreach((array)$images as $image){
				$data['images'][] = $image['image_id'];
			}
			return $data;
		}
}